/*
The surface-physics project: http://code.google.com/p/surface-physics/
Adds real world physics based on the Bullet physics engine, to bases in the Orbiter space
flight simulation software.

Written by Abhijit Nandy
License : Apache License 2.0

Bump_VesselWrapper.h
BulletBase uses this class to control a general Orbiter vessel. The idea is to attach the vessel
in the correct orientation wrt the base so it stays above the Orulex Terrain. Detach it when a
thruster is fired. Landing points are unstable so wasn't used.


TODO: Bump_VesselWrapper objects should be created on the fly by the base after ranging all vessels insim
and only if Orulex is enabled(otherwise default Orbiter behavior rulez!)

*/


#pragma once


#include "BulletBaseVehicle.h"

#include "../BulletBase/Bump_BaseObject.h"


/**
 * The Bump_Attachment to create and manage a BulletBase
 */
class Bump_VesselWrapper : public Bump_BaseObject
{
	static DerivedRegister<Bump_VesselWrapper> reg;
	double cogElev, waitCount;

	const double WAIT_BE4_ATTACH_DELAY;

	//Position wrt base, should this be updated every step ?
	VECTOR3 gposVesselPos, gposMoon, rposVesselPos;

	//Main Attachment point to a BulletBase(only 1 controlling BulletBase possible)
	ATTACHMENTHANDLE atVessel, atBase;
	

	VESSEL3 *vWrappedVessel;



public:


	Bump_VesselWrapper();
	virtual ~Bump_VesselWrapper();

	//Main control functions
	int		init(Bump_BulletBase *bb, char *strObjName, OBJHANDLE hObj = NULL);
	int		poststep(double SimT, double SimDT, double MJD);
	int 	exit();

	//Utility stuff
	int		searchOrbiterVESSEL();
	int		attachOrbiterVESSEL();
	int 	detachOrbiterVESSEL();


};
